﻿CREATE VIEW dbo.v_TrackerRequest
AS
SELECT     TOP (100) PERCENT dbo.t_TrackerRequest.ID AS TrackerRequestID, dbo.t_CarInfo.LoanID, dbo.t_Loan.MsID, dbo.t_TrackerRequest.StatusID, 
                      dbo.v_Menu_10.MenuName AS StatusName, dbo.t_TrackerRequest.TechnicianID, v_Technician.Name AS Technician, 
                      dbo.Date_Format(dbo.t_TrackerRequest.StatusDate, '5') AS DateLast, dbo.t_TrackerRequest.StatusUser AS UserName, CONVERT(char(8), GETDATE() 
                      - dbo.t_TrackerRequest.StatusDate, 108) AS Age, dbo.v_Menu_10.IsList AS IsActive, dbo.t_TrackerRequest.VIN, dbo.t_TrackerRequest.DealerID, 
                      dbo.t_TrackerRequest.Color, dbo.t_TrackerRequest.Mileage, dbo.t_Dealer.Name AS Dealer, dbo.t_Car.Description
FROM         dbo.t_TrackerRequest INNER JOIN
                      dbo.v_Technician AS v_Technician ON dbo.t_TrackerRequest.TechnicianID = v_Technician.ID INNER JOIN
                      dbo.v_Menu_10 ON dbo.t_TrackerRequest.StatusID = dbo.v_Menu_10.MenuID INNER JOIN
                      dbo.t_Dealer ON dbo.t_TrackerRequest.DealerID = dbo.t_Dealer.ID LEFT OUTER JOIN
                      dbo.t_Car ON dbo.t_TrackerRequest.VIN = dbo.t_Car.VIN LEFT OUTER JOIN
                      dbo.t_CarInfo INNER JOIN
                      dbo.t_Loan ON dbo.t_CarInfo.LoanID = dbo.t_Loan.ID ON dbo.t_TrackerRequest.VIN = dbo.t_CarInfo.VIN

GO
EXECUTE sp_addextendedproperty @name = N'MS_DiagramPane1', @value = N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[40] 4[27] 2[14] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1 [50] 4 [25] 3))"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1[50] 2[25] 3) )"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4 [30] 2 [40] 3))"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1[56] 3) )"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2 [66] 3))"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4 [50] 3))"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1[56] 4[18] 2) )"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1[63] 4) )"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4))"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2))"
      End
      ActivePaneConfig = 0
   End
   Begin DiagramPane = 
      Begin Origin = 
         Top = 0
         Left = 0
      End
      Begin Tables = 
         Begin Table = "v_Menu_10"
            Begin Extent = 
               Top = 430
               Left = 116
               Bottom = 684
               Right = 278
            End
            DisplayFlags = 280
            TopColumn = 6
         End
         Begin Table = "t_TrackerRequest"
            Begin Extent = 
               Top = 6
               Left = 38
               Bottom = 221
               Right = 189
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "t_Dealer"
            Begin Extent = 
               Top = 15
               Left = 332
               Bottom = 124
               Right = 490
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "t_CarInfo"
            Begin Extent = 
               Top = 149
               Left = 471
               Bottom = 258
               Right = 623
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "v_Technician"
            Begin Extent = 
               Top = 339
               Left = 540
               Bottom = 448
               Right = 691
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "t_Loan"
            Begin Extent = 
               Top = 124
               Left = 792
               Bottom = 280
               Right = 972
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "t_Car"
            Begin Extent = 
               Top = 322
               Left = 309
               Bottom = 535
               Right = 460
            End
            D', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'VIEW', @level1name = N'v_TrackerRequest';


GO
EXECUTE sp_addextendedproperty @name = N'MS_DiagramPane2', @value = N'isplayFlags = 280
            TopColumn = 0
         End
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
      Begin ColumnWidths = 16
         Width = 284
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1755
         Width = 1395
         Width = 1500
         Width = 6870
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
      End
   End
   Begin CriteriaPane = 
      Begin ColumnWidths = 11
         Column = 8940
         Alias = 1800
         Table = 2310
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 1350
         SortOrder = 1410
         GroupBy = 1350
         Filter = 1350
         Or = 1350
         Or = 1350
         Or = 1350
      End
   End
End', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'VIEW', @level1name = N'v_TrackerRequest';


GO
EXECUTE sp_addextendedproperty @name = N'MS_DiagramPaneCount', @value = 2, @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'VIEW', @level1name = N'v_TrackerRequest';

